/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.dandsoft.mavrep.web;

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author fin
 */
public class ErrorModel extends ModelAndView{


    public ErrorModel(Integer statusCode, Throwable t) {
        super("error", createModel(statusCode, t));
    }

    private static Map createModel(Integer statusCode, Throwable t) {
        Map model  = new HashMap();
        model.put("message", t.getLocalizedMessage());
        model.put("exception", t);
        model.put("statusCode", statusCode != null ? statusCode : "");
        return model;
    }
}
